package bairui.international.model.domain.jpa;

import com.lianjing.sh.model.uml.model.file.TBSuper_FileBase;

/**
 *
 * (抽奖)TB_Prize
 *
 * @说明
 * <pre>

 * </pre>
 *
 * @see Help_TB_Prize#inheritance() 继承体系信息
 *
 */
@org.hibernate.annotations.DynamicInsert
@org.hibernate.annotations.DynamicUpdate

@javax.persistence.Entity(name="t_prize")
@com.lianjing.sh.processing.info.annotation.GenerateInfoModel
@SuppressWarnings("serial")
@com.lianjing.sh.model.common.annotation.Comment("抽奖")
@com.lianjing.sh.processing.info.annotation.InfoComment("抽奖")
public class TB_Prize
 extends TBSuper_FileBase
 implements 
	com.lianjing.sh.model.common.stardard.TableModel<Long>,
	com.sh_lianjing.state.HasStatable,
	java.io.Serializable

{

	
	
	/**
	 * 必须属性赋值接口
	 */
	public static interface MustProperties{
		/** 名称 */
		public String getName();
		/** 文档 */
		public String getFileUrl();
		/** 类型 */
		public String getType();
		/** 原名称 */
		public String getOriginalName();
		/** 大小 */
		public Double getSize();
		/** 标题 */
		public String getTitle();
		/** 状态 */
		public bairui.international.model.status.State_Prize getState();
		/** 计划结束时间 */
		public java.util.Date getFinishTime();
	}
	
	/**
	 * 为必须属性赋值
	 */
	public TB_Prize properties(MustProperties properties) {
		this.setName(properties.getName());
		this.setFileUrl(properties.getFileUrl());
		this.setType(properties.getType());
		this.setOriginalName(properties.getOriginalName());
		this.setSize(properties.getSize());
		this.setTitle(properties.getTitle());
		this.setState(properties.getState());
		this.setFinishTime(properties.getFinishTime());
		return this;
	}
	
	/**
	 *	必须属性构造函数
	 */
	public TB_Prize(MustProperties properties) {
		this.properties(properties);
	}
	
	
	/**
	 * 可选单属性赋值接口
	 */
	public static interface OptionalSingleProperties{
		/** 说明 */
		public String getContent();
		/** 实际结束时间 */
		public java.util.Date getRealFinishTime();
		/** 发布时间 */
		public java.util.Date getPublishTime();
		/** 强制结束标志 */
		public Boolean getForceFinishFlag();
	}
	
	/**
	 * 为可选单属性赋值
	 */
	public TB_Prize properties(OptionalSingleProperties properties) {
		this.setContent(properties.getContent());
		this.setRealFinishTime(properties.getRealFinishTime());
		this.setPublishTime(properties.getPublishTime());
		this.setForceFinishFlag(properties.getForceFinishFlag());
		return this;
	}
	
	
	
	public TB_Prize(MustProperties must, OptionalSingleProperties optionalSingle) {
		this.properties(must);
		this.properties(optionalSingle);
	}
	
	/**
	 * 仅当前必须属性赋值接口
	 */
	public static interface CurrentMustProperties{
		/** 标题 */
		public String getTitle();
		/** 状态 */
		public bairui.international.model.status.State_Prize getState();
		/** 计划结束时间 */
		public java.util.Date getFinishTime();
	}
	
	/**
	 * 为仅当前必须属性赋值
	 */
	public TB_Prize properties(CurrentMustProperties properties) {
		this.setTitle(properties.getTitle());
		this.setState(properties.getState());
		this.setFinishTime(properties.getFinishTime());
		return this;
	}
	
	/**
	 * 仅当前可选单属性赋值接口
	 */
	public static interface CurrentOptionalSingleProperties{
		/** 说明 */
		public String getContent();
		/** 实际结束时间 */
		public java.util.Date getRealFinishTime();
		/** 发布时间 */
		public java.util.Date getPublishTime();
		/** 强制结束标志 */
		public Boolean getForceFinishFlag();
	}
	
	/**
	 * 为仅当前可选单属性赋值
	 */
	public TB_Prize properties(CurrentOptionalSingleProperties properties) {
		this.setContent(properties.getContent());
		this.setRealFinishTime(properties.getRealFinishTime());
		this.setPublishTime(properties.getPublishTime());
		this.setForceFinishFlag(properties.getForceFinishFlag());
		return this;
	}
	
	public TB_Prize(
		@lombok.NonNull com.lianjing.sh.model.uml.model.file.TBSuper_FileBase bean,
		CurrentMustProperties mustProperties,
		CurrentOptionalSingleProperties optionalProperties
	) {
		this(bean);
		this.properties(mustProperties);
		this.properties(optionalProperties);
	}
	
	public TB_Prize(
		@lombok.NonNull com.lianjing.sh.model.uml.model.file.TBSuper_FileBase bean
	) {
		update(bean);
	}
	
	public TB_Prize update(com.lianjing.sh.model.uml.model.file.TBSuper_FileBase bean){
		this.setId(bean.getId());
		this.setCreateTime(bean.getCreateTime());
		this.setModifyTime(bean.getModifyTime());
		this.setOrderValue(bean.getOrderValue());
		this.setName(bean.getName());
		this.setFileUrl(bean.getFileUrl());
		this.setType(bean.getType());
		this.setOriginalName(bean.getOriginalName());
		this.setSize(bean.getSize());
		return this;
	}
	
	
	/**
	 * 更新属性内部类
	 */
	public abstract class UpdateProperties {
	
		public UpdateProperties() throws Exception {
			Integer orderValue = getOrderValue(TB_Prize.this);
			if(isOverride_getOrderValue){
				TB_Prize.this.setOrderValue(orderValue);
			}
	
			String name = getName(TB_Prize.this);
			if(isOverride_getName){
				TB_Prize.this.setName(name);
			}
	
			String fileUrl = getFileUrl(TB_Prize.this);
			if(isOverride_getFileUrl){
				TB_Prize.this.setFileUrl(fileUrl);
			}
	
			String type = getType(TB_Prize.this);
			if(isOverride_getType){
				TB_Prize.this.setType(type);
			}
	
			String originalName = getOriginalName(TB_Prize.this);
			if(isOverride_getOriginalName){
				TB_Prize.this.setOriginalName(originalName);
			}
	
			Double size = getSize(TB_Prize.this);
			if(isOverride_getSize){
				TB_Prize.this.setSize(size);
			}
	
			String title = getTitle(TB_Prize.this);
			if(isOverride_getTitle){
				TB_Prize.this.setTitle(title);
			}
	
			String content = getContent(TB_Prize.this);
			if(isOverride_getContent){
				TB_Prize.this.setContent(content);
			}
	
			bairui.international.model.status.State_Prize state = getState(TB_Prize.this);
			if(isOverride_getState){
				TB_Prize.this.setState(state);
			}
	
			java.util.List<bairui.international.model.domain.jpa.TB_PrizeItem> prizeItems = getPrizeItems(TB_Prize.this);
			if(isOverride_getPrizeItems){
				TB_Prize.this.setPrizeItems(prizeItems);
			}
	
			java.util.Date finishTime = getFinishTime(TB_Prize.this);
			if(isOverride_getFinishTime){
				TB_Prize.this.setFinishTime(finishTime);
			}
	
			java.util.Date realFinishTime = getRealFinishTime(TB_Prize.this);
			if(isOverride_getRealFinishTime){
				TB_Prize.this.setRealFinishTime(realFinishTime);
			}
	
			java.util.Date publishTime = getPublishTime(TB_Prize.this);
			if(isOverride_getPublishTime){
				TB_Prize.this.setPublishTime(publishTime);
			}
	
			java.util.List<bairui.international.model.domain.jpa.TB_WinPrize> winPrizes = getWinPrizes(TB_Prize.this);
			if(isOverride_getWinPrizes){
				TB_Prize.this.setWinPrizes(winPrizes);
			}
	
			Boolean forceFinishFlag = getForceFinishFlag(TB_Prize.this);
			if(isOverride_getForceFinishFlag){
				TB_Prize.this.setForceFinishFlag(forceFinishFlag);
			}
		}
	
		public TB_Prize up(){
			return TB_Prize.this;
		}
	
		/** 排序值 */
		private boolean isOverride_getOrderValue = true;
		public Integer getOrderValue(TB_Prize it) throws Exception { 
			isOverride_getOrderValue = false; 
			return null;
		}
		/** 名称 */
		private boolean isOverride_getName = true;
		public String getName(TB_Prize it) throws Exception { 
			isOverride_getName = false; 
			return null;
		}
		/** 文档 */
		private boolean isOverride_getFileUrl = true;
		public String getFileUrl(TB_Prize it) throws Exception { 
			isOverride_getFileUrl = false; 
			return null;
		}
		/** 类型 */
		private boolean isOverride_getType = true;
		public String getType(TB_Prize it) throws Exception { 
			isOverride_getType = false; 
			return null;
		}
		/** 原名称 */
		private boolean isOverride_getOriginalName = true;
		public String getOriginalName(TB_Prize it) throws Exception { 
			isOverride_getOriginalName = false; 
			return null;
		}
		/** 大小 */
		private boolean isOverride_getSize = true;
		public Double getSize(TB_Prize it) throws Exception { 
			isOverride_getSize = false; 
			return null;
		}
		/** 标题 */
		private boolean isOverride_getTitle = true;
		public String getTitle(TB_Prize it) throws Exception { 
			isOverride_getTitle = false; 
			return null;
		}
		/** 说明 */
		private boolean isOverride_getContent = true;
		public String getContent(TB_Prize it) throws Exception { 
			isOverride_getContent = false; 
			return null;
		}
		/** 状态 */
		private boolean isOverride_getState = true;
		public bairui.international.model.status.State_Prize getState(TB_Prize it) throws Exception { 
			isOverride_getState = false; 
			return null;
		}
		/** 奖品 */
		private boolean isOverride_getPrizeItems = true;
		public java.util.List<bairui.international.model.domain.jpa.TB_PrizeItem> getPrizeItems(TB_Prize it) throws Exception { 
			isOverride_getPrizeItems = false; 
			return null;
		}
		/** 计划结束时间 */
		private boolean isOverride_getFinishTime = true;
		public java.util.Date getFinishTime(TB_Prize it) throws Exception { 
			isOverride_getFinishTime = false; 
			return null;
		}
		/** 实际结束时间 */
		private boolean isOverride_getRealFinishTime = true;
		public java.util.Date getRealFinishTime(TB_Prize it) throws Exception { 
			isOverride_getRealFinishTime = false; 
			return null;
		}
		/** 发布时间 */
		private boolean isOverride_getPublishTime = true;
		public java.util.Date getPublishTime(TB_Prize it) throws Exception { 
			isOverride_getPublishTime = false; 
			return null;
		}
		/** 中奖 */
		private boolean isOverride_getWinPrizes = true;
		public java.util.List<bairui.international.model.domain.jpa.TB_WinPrize> getWinPrizes(TB_Prize it) throws Exception { 
			isOverride_getWinPrizes = false; 
			return null;
		}
		/** 强制结束标志 */
		private boolean isOverride_getForceFinishFlag = true;
		public Boolean getForceFinishFlag(TB_Prize it) throws Exception { 
			isOverride_getForceFinishFlag = false; 
			return null;
		}
	
	}
	
	
	/**
	 * 构造函数
	 */
	public TB_Prize() {
	}
	
	public TB_Prize(
		@lombok.NonNull Long id
	) {
		this.setId(id);
	}
	
	public TB_Prize(
		@lombok.NonNull TB_Prize bean
	) {
		this.setId(bean.getId());
		this.setCreateTime(bean.getCreateTime());
		this.setModifyTime(bean.getModifyTime());
		this.setOrderValue(bean.getOrderValue());
		this.setName(bean.getName());
		this.setFileUrl(bean.getFileUrl());
		this.setType(bean.getType());
		this.setOriginalName(bean.getOriginalName());
		this.setSize(bean.getSize());
		this.setTitle(bean.getTitle());
		this.setContent(bean.getContent());
		this.setState(bean.getState());
		this.setCreator(bean.getCreator());
		this.setLastModifier(bean.getLastModifier());
		this.setPrizeItems(bean.getPrizeItems());
		this.setFinishTime(bean.getFinishTime());
		this.setRealFinishTime(bean.getRealFinishTime());
		this.setPublishTime(bean.getPublishTime());
		this.setWinPrizes(bean.getWinPrizes());
		this.setForceFinishFlag(bean.getForceFinishFlag());
	}
	
	

	


	/**
	 * 属性
	 */
	@com.lianjing.sh.model.common.annotation.Comment("标题")
	@com.lianjing.sh.processing.info.annotation.InfoComment("标题")
	@javax.persistence.Column(name="title", nullable=false, length=100)
	private String title;

	@com.lianjing.sh.model.common.annotation.Comment("说明")
	@com.lianjing.sh.processing.info.annotation.InfoComment("说明")
	@javax.persistence.Lob
	@javax.persistence.Column(name="content", length=20000)
	private String content;

	@com.lianjing.sh.model.common.annotation.Comment("状态")
	@com.lianjing.sh.processing.info.annotation.InfoComment("状态")
	@javax.persistence.Enumerated(javax.persistence.EnumType.STRING)
	@javax.persistence.Column(name="state", nullable=false)
	private bairui.international.model.status.State_Prize state;

	@com.lianjing.sh.model.common.annotation.Comment("创建者")
	@com.lianjing.sh.processing.info.annotation.InfoComment("创建者")
	@com.querydsl.core.annotations.QueryInit("*.*.*")
	@javax.persistence.JoinColumn(name="creator_id", nullable=false)
	@javax.persistence.ManyToOne(optional=false)
	private bairui.international.model.domain.jpa.TB_Admin creator;

	@com.lianjing.sh.model.common.annotation.Comment("最后修改者")
	@com.lianjing.sh.processing.info.annotation.InfoComment("最后修改者")
	@com.querydsl.core.annotations.QueryInit("*.*.*")
	@javax.persistence.JoinColumn(name="lastModifier_id", nullable=true)
	@javax.persistence.ManyToOne()
	private bairui.international.model.domain.jpa.TB_Admin lastModifier;

	@com.lianjing.sh.model.common.annotation.Comment("奖品")
	@com.lianjing.sh.processing.info.annotation.InfoComment("奖品")
	@com.querydsl.core.annotations.QueryInit("*.*.*")
	@javax.persistence.OneToMany(cascade={javax.persistence.CascadeType.ALL}, mappedBy="prize")
	private java.util.List<bairui.international.model.domain.jpa.TB_PrizeItem> prizeItems;

	@com.lianjing.sh.model.common.annotation.Comment("计划结束时间")
	@com.lianjing.sh.processing.info.annotation.InfoComment("计划结束时间")
	@javax.persistence.Column(name="finishTime", nullable=false)
	private java.util.Date finishTime;

	@com.lianjing.sh.model.common.annotation.Comment("实际结束时间")
	@com.lianjing.sh.processing.info.annotation.InfoComment("实际结束时间")
	@javax.persistence.Column(name="realFinishTime")
	private java.util.Date realFinishTime;

	@com.lianjing.sh.model.common.annotation.Comment("发布时间")
	@com.lianjing.sh.processing.info.annotation.InfoComment("发布时间")
	@javax.persistence.Column(name="publishTime")
	private java.util.Date publishTime;

	@com.lianjing.sh.model.common.annotation.Comment("中奖")
	@com.lianjing.sh.processing.info.annotation.InfoComment("中奖")
	@com.querydsl.core.annotations.QueryInit("*.*.*")
	@javax.persistence.OneToMany(mappedBy="prize")
	private java.util.List<bairui.international.model.domain.jpa.TB_WinPrize> winPrizes;

	@com.lianjing.sh.model.common.annotation.Comment("强制结束标志")
	@com.lianjing.sh.processing.info.annotation.InfoComment("强制结束标志")
	@javax.persistence.Column(name="forceFinishFlag")
	private Boolean forceFinishFlag;

	/** get[标题] */
	public String getTitle() {
		return this.title;
	}

	/** get[说明] */
	public String getContent() {
		return this.content;
	}

	/** get[状态] */
	public bairui.international.model.status.State_Prize getState() {
		return this.state;
	}

	/** get[创建者] */
	public bairui.international.model.domain.jpa.TB_Admin getCreator() {
		return this.creator;
	}

	/** get[最后修改者] */
	public bairui.international.model.domain.jpa.TB_Admin getLastModifier() {
		return this.lastModifier;
	}

	/** get[奖品] */
	public java.util.List<bairui.international.model.domain.jpa.TB_PrizeItem> getPrizeItems() {
		return this.prizeItems;
	}

	/** get[计划结束时间] */
	public java.util.Date getFinishTime() {
		return this.finishTime;
	}

	/** get[实际结束时间] */
	public java.util.Date getRealFinishTime() {
		return this.realFinishTime;
	}

	/** get[发布时间] */
	public java.util.Date getPublishTime() {
		return this.publishTime;
	}

	/** get[中奖] */
	public java.util.List<bairui.international.model.domain.jpa.TB_WinPrize> getWinPrizes() {
		return this.winPrizes;
	}

	/** get[强制结束标志] */
	public Boolean getForceFinishFlag() {
		return this.forceFinishFlag;
	}

	/** set[标题] */
	public void setTitle(String title) {
		this.title = title;
	}

	/** set[说明] */
	public void setContent(String content) {
		this.content = content;
	}

	/** set[状态] */
	public void setState(bairui.international.model.status.State_Prize state) {
		this.state = state;
	}

	/** set[创建者] */
	public void setCreator(bairui.international.model.domain.jpa.TB_Admin creator) {
		this.creator = creator;
	}

	/** set[最后修改者] */
	public void setLastModifier(bairui.international.model.domain.jpa.TB_Admin lastModifier) {
		this.lastModifier = lastModifier;
	}

	/** set[奖品] */
	public void setPrizeItems(java.util.List<bairui.international.model.domain.jpa.TB_PrizeItem> prizeItems) {
		this.prizeItems = prizeItems;
	}

	/** set[计划结束时间] */
	public void setFinishTime(java.util.Date finishTime) {
		this.finishTime = finishTime;
	}

	/** set[实际结束时间] */
	public void setRealFinishTime(java.util.Date realFinishTime) {
		this.realFinishTime = realFinishTime;
	}

	/** set[发布时间] */
	public void setPublishTime(java.util.Date publishTime) {
		this.publishTime = publishTime;
	}

	/** set[中奖] */
	public void setWinPrizes(java.util.List<bairui.international.model.domain.jpa.TB_WinPrize> winPrizes) {
		this.winPrizes = winPrizes;
	}

	/** set[强制结束标志] */
	public void setForceFinishFlag(Boolean forceFinishFlag) {
		this.forceFinishFlag = forceFinishFlag;
	}





	/** add[PrizeItems] */
	public TB_Prize addPrizeItems(bairui.international.model.domain.jpa.TB_PrizeItem ... prizeItems){
		if(this.prizeItems == null){
			this.prizeItems = new java.util.ArrayList<>();
		}
		for(bairui.international.model.domain.jpa.TB_PrizeItem bean : prizeItems){
			bean.setPrize(this);
			this.prizeItems.add(bean);
		}
		return this;
	}
	/** add[WinPrizes] */
	public TB_Prize addWinPrizes(bairui.international.model.domain.jpa.TB_WinPrize ... winPrizes){
		if(this.winPrizes == null){
			this.winPrizes = new java.util.ArrayList<>();
		}
		for(bairui.international.model.domain.jpa.TB_WinPrize bean : winPrizes){
			bean.setPrize(this);
			this.winPrizes.add(bean);
		}
		return this;
	}
	
	/** remove[PrizeItems] */
	public TB_Prize removePrizeItems(bairui.international.model.domain.jpa.TB_PrizeItem ... prizeItems){
		if(this.prizeItems == null){
			return this;
		}
		for(bairui.international.model.domain.jpa.TB_PrizeItem bean : prizeItems){
			bean.setPrize(null);
			this.prizeItems.remove(bean);
		}
		return this;
	}
	/** remove[WinPrizes] */
	public TB_Prize removeWinPrizes(bairui.international.model.domain.jpa.TB_WinPrize ... winPrizes){
		if(this.winPrizes == null){
			return this;
		}
		for(bairui.international.model.domain.jpa.TB_WinPrize bean : winPrizes){
			bean.setPrize(null);
			this.winPrizes.remove(bean);
		}
		return this;
	}
	
	/**
	 * contains[PrizeItems]
	 *
	 * 全部输入都包含：返回 true
	 * 输入中有至少有一个不包含：返回 false
	 */
	public boolean containsPrizeItems(bairui.international.model.domain.jpa.TB_PrizeItem ... prizeItems){
		if(this.prizeItems == null || prizeItems==null || prizeItems.length<=0){
			return false;
		}
		return this.prizeItems.containsAll(java.util.Arrays.asList(prizeItems));
	}
	/**
	 * contains[WinPrizes]
	 *
	 * 全部输入都包含：返回 true
	 * 输入中有至少有一个不包含：返回 false
	 */
	public boolean containsWinPrizes(bairui.international.model.domain.jpa.TB_WinPrize ... winPrizes){
		if(this.winPrizes == null || winPrizes==null || winPrizes.length<=0){
			return false;
		}
		return this.winPrizes.containsAll(java.util.Arrays.asList(winPrizes));
	}
	

	/** take[创建者] */
	public bairui.international.model.domain.jpa.TB_Admin takeCreator(){
		if(null == this.creator){
			this.creator = new bairui.international.model.domain.jpa.TB_Admin();
		}
		return this.creator;
	}
	
	/** take[最后修改者] */
	public bairui.international.model.domain.jpa.TB_Admin takeLastModifier(){
		if(null == this.lastModifier){
			this.lastModifier = new bairui.international.model.domain.jpa.TB_Admin();
		}
		return this.lastModifier;
	}
	
	/** must[创建者] */
	public bairui.international.model.domain.jpa.TB_Admin mustCreator() {
		return this.creator;
	}
	
	/** optional[最后修改者] */
	public java.util.Optional<bairui.international.model.domain.jpa.TB_Admin> optionalLastModifier() {
		return java.util.Optional.ofNullable(this.lastModifier);
	}
	

	/**
	 * 复写 hashCode
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		return prime * result + ((this.getId() == null) ? 0 : this.getId().hashCode());
	}
	
	/**
	 * 复写 equals
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj){
			return true;
		}
		if (obj == null){
			return false;
		}
		if (getClass() != obj.getClass()){
			return false;
		}
		TB_Prize other = (TB_Prize) obj;
		if (this.getId() == null) {
			return false;
		} else if (!this.getId().equals(other.getId())){
			return false;
		}
		return true;
	}
	

	/**
	 * 用来覆盖toString()的输出
	 */
	@javax.persistence.Transient
	private String toString;
	
	public void setToString(String toString) {
		this.toString = toString;
	}
	
	/**
	 * 复写 toString
	 */
	@Override
	public String toString() {
		if(null != this.toString){
			return this.toString;
		}
		String name = this.getName();
		if(null != name){
			return String.valueOf(name);
		}
		return super.toString();
	}	

	@javax.persistence.PrePersist
	public void prePersist() {
		com.lianjing.sh.web.security.authority.login.LoginUserInfo userInfo = com.lianjing.sh.web.security.authority.login.Util_Login.getInfo();
		Object user = null == userInfo ? null : userInfo.getUser();
		this.setCreateTime(new java.util.Date());
		this.setModifyTime(new java.util.Date());
		this.setCreator((bairui.international.model.domain.jpa.TB_Admin)user);
		this.setLastModifier((bairui.international.model.domain.jpa.TB_Admin)user);
	}
	
	@javax.persistence.PreUpdate
	public void preUpdate() {
		com.lianjing.sh.web.security.authority.login.LoginUserInfo userInfo = com.lianjing.sh.web.security.authority.login.Util_Login.getInfo();
		Object user = null == userInfo ? null : userInfo.getUser();
		this.setModifyTime(new java.util.Date());
		this.setLastModifier((bairui.international.model.domain.jpa.TB_Admin)user);
	}

	/**
	 * 状态相关
	 */
	public bairui.international.model.status.State_Prize state(){
		return this.getState();
	}


}
